package com.dgut.lotterySystem.dao.mapper;

import com.dgut.lotterySystem.dao.dataObject.ActivityDO;
import com.dgut.lotterySystem.service.enums.ActivityEnum;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name,description,status) values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void createActivity(ActivityDO activityDO);

    @Select("select count(*) from activity")
    Integer count();
    @Select("select id,activity_name,description,status from activity order by id desc limit #{offset},#{pageSize}")
    List<ActivityDO> findActivityList(Integer offset,Integer pageSize);

    @Select("select * from activity where id=#{activityId}")
    ActivityDO findActivityInfoById(Long activityId);

    @Update("update activity set status=#{status} where id=#{activityId}")
    void updateStatus(@Param("activityId") Long activityId, @Param("status") String status);
}
